/*
 *
 * Copyright 2017-2018. All rights reserved.
 *
 * This copyrighted material is made available to anyone wishing to use, modify,
 * copy, or redistribute it subject to the terms and conditions of the GNU
 * Lesser General Public License, as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
 * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public License
 * for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this distribution; if not, see <http://www.gnu.org/licenses/>.
 *
 */
package com.loveprogrammer.eternity.enums;

import java.util.Arrays;
import java.util.Objects;
import java.util.Optional;

/**
 * 种族
 *
 * @author eric
 * @version 1.0.0
 */
public enum QualityEnum {

    白色("white", "普通",1d, ConsoleColors.RESET, 1),
    蓝色("blue", "进阶",1.3d, ConsoleColors.BLUE, 2),
    黄色("yellow", "优质",1.6d, ConsoleColors.YELLOW_BRIGHT,3),
    紫色("purple", "卓越",1.95d, ConsoleColors.PURPLE,4),
    红色("red", "传奇",2.4d, ConsoleColors.RED,5),
    暗金("gold", "史诗",2.9d, ConsoleColors.YELLOW,6),
    绿色("green", "套装",3.1d, ConsoleColors.GREEN_BOLD_BRIGHT,7);

    private String code;

    private String desc;

    private Double ratio;

    private String color;

    private int id;

    QualityEnum(String code, String desc, Double ratio, String color, int id) {
        this.code = code;
        this.desc = desc;
        this.ratio = ratio;
        this.color = color;
        this.id = id;
    }

    public static QualityEnum getById(int id){
        Optional<QualityEnum> optional =
                Arrays.stream(QualityEnum.values())
                        .filter(v -> Objects.equals(v.getId(), id))
                        .findFirst();

        return optional.orElse(QualityEnum.白色);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }

    public Double getRatio() {
        return ratio;
    }

    public String getColor() {
        return color;
    }

    public int getId() {
        return id;
    }
}
